# 5. 全量和已占用字符集、字符串统计
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on('line', (input) => {
const input = 'a:3,b:5,c:2@a:1,b:2';
const arr = input.split('@');
const fullStr = arr[0];
const hasStr = arr[1];
let fullArr = fullStr.split(',');
let hasArr = hasStr.split(',');
let fullObj = {};
for(let i=0; i<fullArr.length; i++) {
let arr1 = fullArr[i].split(':');
fullObj[arr1[0]] = arr1[1];
}
for(let i=0; i<hasArr.length; i++) {
let arr1 = hasArr[i].split(':');
if (fullObj[arr1[0]]) {
fullObj[arr1[0]] = fullObj[arr1[0]] - arr1[1];
}
}
let ans = [];
for(let i in fullObj) {
if (fullObj[i] > 0) {
ans.push(`${i}:${fullObj[i]}`);
}
}
console.log(ans.join(','));
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33